<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    //console.log(a);//(1) undefined 已定义未赋值
    //var a = 0;
    //function fun(){ //函数内部重新进行预解析
    //    console.log(a) // （第三）undefined
    //    var a = 2;
    //    console.log(a);//（第四） 2
    //}
    //console.log(a);// (第2) 0
    //fun()
    //console.log(a);//（第五）  0




    console.log(a);//undefined
    var a =0;
    function fn(){
        console.log(a);//0
        a=2
        console.log(a);//2
    }
    console.log(a);//0
    fn()
    console.log(a);//2
</script>
</html>